window: Maintain accessible HIDDEN state
authorMatthias Clasen <mclasen@redhat.com>
Sat, 24 Oct 2020 19:23:12 +0000 (15:23 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 24 Oct 2020 19:25:03 +0000 (15:25 -0400)
We want to use the HIDDEN state to control when
things get added and removed from the accessible
tree, so ensure that we a) set HIDDEN to true
initially for windows, and b) we update HIDDEN
when a window is shown or hidden.

The second part is handled by gtk_widget_hide
for other widgets, but hiding a window does not
always go through that code path.

gtk/gtkwindow.c

index 3f59e4e02c6f15478a690bebe616359d0245600f..ed20087a29be798eaad6e545b53c3c695faf77f0 100644 (file)
@@ -1554,6 +1554,11 @@ gtk_window_constructed (GObject *object)
   gtk_widget_add_controller (GTK_WIDGET (object), GTK_EVENT_CONTROLLER (priv->click_gesture));
 
   g_list_store_append (toplevel_list, window);
+
+  gtk_accessible_update_state (GTK_ACCESSIBLE (window),
+                               GTK_ACCESSIBLE_STATE_HIDDEN, TRUE,
+                               -1);
+
   g_object_unref (window);
 }
 
@@ -7190,11 +7195,16 @@ gtk_window_destroy (GtkWindow *window)
     return;
 
   g_object_ref (window);
+
   gtk_tooltip_unset_surface (GTK_NATIVE (window));
 
+  gtk_window_hide (GTK_WIDGET (window));
+  gtk_accessible_update_state (GTK_ACCESSIBLE (window),
+                               GTK_ACCESSIBLE_STATE_HIDDEN, TRUE,
+                               -1);
+
   g_list_store_remove (toplevel_list, i);
 
-  gtk_window_hide (GTK_WIDGET (window));
   gtk_widget_unrealize (GTK_WIDGET (window));
 
   g_object_unref (window);